package com.zryc.shop.config;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

//重写RequestOriginParser接口的默认行为
@Component
public class RequestOriginParserDefinition implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {
        //除了参数进行限制，也可以加载请求头header上（对于请求头的判断更多）
        //String header = httpServletRequest.getHeader("Token");//只有带这个Token请求头的才放行
        return httpServletRequest.getParameter("SN");//serviceName的简写
    }
}
